package com.systop.dxjj.modules.orders.controller;

import com.alibaba.fastjson.JSON;
import com.systop.dxjj.common.pojo.*;
import com.systop.dxjj.common.utils.JwtUtil;
import com.systop.dxjj.common.utils.R;
import com.systop.dxjj.common.utils.RedisCache;
import com.systop.dxjj.modules.orders.service.OrdersService;
import com.systop.dxjj.modules.recruitinfo.service.RecruitinfoService;
import com.systop.dxjj.modules.student.mapper.StudentMapper;
import com.systop.dxjj.modules.student.service.StudentService;
import com.systop.dxjj.modules.teacher.service.TeacherService;
import io.jsonwebtoken.Claims;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@Api("订单管理模块")
public class OrdersController {

    @Autowired
    OrdersService ordersService;

    @GetMapping("/getOrdersById/{orderid}")
    @ApiOperation(value = "根据id查询订单信息",notes = "订单信息")
    public R getOrdersById(@PathVariable Integer orderid){
       return ordersService.getById(orderid);
    }

    @GetMapping("/getAllOrders")
    @ApiOperation(value = "查询所有订单信息",notes = "订单信息")
    public R getAllOrders(){
        return ordersService.getAll();
    }

    @GetMapping ("/deleteOrdersById/{orderid}")
    @ApiOperation(value = "删除订单信息",notes = "订单信息")
    public R deleteOrdersById(@PathVariable Integer orderid) {
        return ordersService.deleteById(orderid);
    }

    @GetMapping("/updateStatue/{orderid}")
    @ApiOperation(value = "修改订单信息状态",notes = "订单信息")
    public Integer updateOrderStatue(@PathVariable Integer orderid){
        return ordersService.updateOrderStatue(orderid);
    }

    @GetMapping("/getOrdersByTeachId")
    @ApiOperation(value = "查询教师本人订单",notes = "订单信息")
    public R getOrdersByTeachId(HttpServletRequest request){
        return ordersService.getByTeachId(request);
    }

    @GetMapping("/addOrders/{recruitid}")
    public R addOrders(@PathVariable Integer recruitid, HttpServletRequest request){
       return ordersService.addOrders(recruitid,request);
    }
}

